﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using CNotebook;
using CNotebook.Sales;

namespace NotebookS2
{
    public partial class BRW_AGING : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public BRW_AGING()
        {
            InitializeComponent();
        }
        public string ConnectionString { get; set; }
        private void btnPreview_Click(object sender, EventArgs e)
        {
            DeliveryManager oManager = new DeliveryManager();

            oManager.ConnectionString = this.ConnectionString;
            oManager.Open();

            DataTable dt = oManager.GetAgingInvoices(cboSearch.SelectedIndex, Convert.ToDateTime(dtAsOf.EditValue));

            gridControl1.DataSource = dt;
            gridControl1.Refresh();

            oManager.Close();
        }

        private void ribbon_Click(object sender, EventArgs e)
        {

        }

        public void PrintPreview()
        {
            if (!gridControl1.IsPrintingAvailable)
            {
                MessageBox.Show("The 'DevExpress.XtraPrinting' Library is not found", "Error");
                return;
            }
            // Opens the Preview window. 
            
            gridControl1.ShowPrintPreview();
        }

        private void BRW_InvoiceAgingViewer_Load(object sender, EventArgs e)
        {
            gridControl1.ShowRibbonPrintPreview();
            cboSearch.SelectedIndex = 0;
            dtAsOf.EditValue = System.DateTime.Now;
        }
    }
}